package com.easylinkin.linkappapi.linkage.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.easylinkin.linkappapi.common.model.RequestModel;
import com.easylinkin.linkappapi.linkage.entity.LinkageLog;
import com.easylinkin.linkappapi.linkage.service.LinkageLogService;
import javax.annotation.Resource;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;

/**
 * <p>
 * 联动执行日志 前端控制器
 * </p>
 *
 * @author TongJie
 * @since 2020-06-09
 */
@RestController
@RequestMapping("/linkage/linkageLog")
public class LinkageLogController {


    @Resource
    private LinkageLogService service;

    @PostMapping("getPage")
    public RestMessage getIntelligentTasksPage(@RequestBody RequestModel<LinkageLog> requestModel) {
        Assert.notNull(requestModel.getCustomQueryParams(), "customQueryParams 不能为空");
        Assert.notNull(requestModel.getPage(), "page 不能为空");
        IPage<LinkageLog> record = service.getLinkageLogPage(requestModel.getPage(), requestModel.getCustomQueryParams());
        return RestBuilders.successBuilder().data(record).build();
    }

    @PostMapping("getById")
    public RestMessage getById(@RequestParam("id") String id) {
        Assert.hasLength(id, "id 不能为空");
        return RestBuilders.successBuilder().data(service.getLinkageLog(id)).build();
    }

}
